package com.dayaokeji.rhythmschoolstudent.client.common.resource;

import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dayaokeji.rhythmschoolstudent.R;
import com.dayaokeji.rhythmschoolstudent.utils.FileExtUtil;
import com.dayaokeji.rhythmschoolstudent.utils.FileUtil;
import com.dayaokeji.server_api.domain.FileInfo;
import com.litesuits.common.io.FilenameUtils;

/**
 * Created by Zeno on 2017/10/3.
 * 资源共享
 */

public class SharedResourceAdapter extends BaseQuickAdapter<FileInfo,BaseViewHolder> {


    public SharedResourceAdapter() {
        super(R.layout.item_resource_list, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, FileInfo fileInfo) {

        String extension = FilenameUtils.getExtension(fileInfo.getName());
        ((ImageView) baseViewHolder.getView(R.id.iv_file_icon)).setImageResource(FileExtUtil.INSTANCE.getFileExtIcon(extension));

        baseViewHolder.setText(R.id.tv_file_name,fileInfo.getName());
        baseViewHolder.setText(R.id.tv_create_time,mContext.getString(R.string.upload_time, fileInfo.getCreateTime()));
    }
}
